package com.zjitc;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/10 15:45
 * @description:
 */
public class MyRedis {

  private JedisPool jedisPool;

  public MyRedis(JedisPool pool){
    this.jedisPool = pool;
  }

  public void hest(String key, String field, String value){
    Jedis jedis = null;
    try {
      Jedis con = this.jedisPool.getResource();
      con.hset(key, field, value);
    }finally {
      this.jedisPool.returnResource(jedis);
    }
  }

  public Jedis getResource(){
    return this.jedisPool.getResource();
  }

  public void returnResource(final  Jedis jedis){
    this.jedisPool.returnResource(jedis);
  }
}
